/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cn.ekuma.epos.datalogic.define.dao;

import cn.ekuma.data.dao.ModifiedLogDAO;
import com.openbravo.bean.ServiceCalendar;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.DataWrite;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.Session;
import com.openbravo.data.loader.TableDefinition;
import com.openbravo.data.model.Field;
import com.openbravo.format.Formats;

/**
 *
 * @author Administrator
 */
public class ServiceCalendarDAO extends ModifiedLogDAO<ServiceCalendar>{

    public ServiceCalendarDAO(I_Session s) {
        super(s);
    }

    @Override
    public TableDefinition getTable() {
         return new TableDefinition(s,
                "SERVICECALENDAR",
                new Field[]{
                          new Field("ID",Datas.STRING,Formats.STRING),
                          new Field("NAME",Datas.STRING,Formats.STRING),
                          new Field("LASTMODIFIED",Datas.TIMESTAMP, Formats.TIMESTAMP)
                },
                new int[]{0});
    }

    @Override
    public void writeInsertValues(DataWrite dp, ServiceCalendar obj) throws BasicException {
          dp.setString(1, obj.getId());
          dp.setString(2,obj.getName());
          dp.setTimestamp(3,obj.getLastModified());
    }

    @Override
    public Class getSuportClass() {
        return ServiceCalendar.class;
    }

    public ServiceCalendar readValues(DataRead dr,ServiceCalendar obj) throws BasicException {
        if(obj==null)
        	obj=new ServiceCalendar();
        obj.setId(dr.getString(1));
        obj.setName(dr.getString(2));
        obj.setLastModified(dr.getTimestamp(3));
        return obj;
    }

}
